<template>
	<view>
		<view class="tips u-m-b-10">
			<u-icon class="u-m-r-10"
				name="https://aihelp.oss-cn-hangzhou.aliyuncs.com/public/base/2023/11/13/c4fc9d4dcecb4e4a9cb8bf17a511e221.png"
				size="32"></u-icon>
			同校去向：报考了该大学专业的同学被以下大学调剂录取了:
		</view>
		<view class="u-font-28 u-m-b-20">
			<view class="colorF7 word-break-all">
				{{msg}}
			</view>
		</view>
		<view>
			<wyb-table headerBgColor="#F9F9F9" showLeftAndRightBorder showLeftAndRightBorder ref="table" :headers="txHeaders"
				:contents="txTableData" width="100%" />
		</view>
		<view class="u-m-t-40">
			<u-loadmore :status="status" />
		</view>
	</view>
</template>

<script>
	import wybTable from '../wyb-table/wyb-table.vue'
	import {
		getAdjustGoList,
	} from '@/api/school.js';
	export default {
		props:['schoolCode','majorCode'],
		components: {
			wybTable
		},
		data() {
			return {
				msg:"",
				status: 'loadmore',
				txGoPage: {
					pageSize: 20,
					pageNum: 1,
				},
				txTableData: [],
				txHeaders: [{
					label: '年份',
					key: 'year',
					width: 80
				}, {
					label: '姓名',
					key: 'name',
					width: 80
				}, {
					label: '初试总分',
					key: 'total',
					width: 80
				}, {
					label: '英语',
					key: 'english',
					width: 80
				}, {
					label: '政治',
					key: 'politics',
					width: 80
				}, {
					label: '专一',
					key: 'specialityOne',
					width: 80
				}, {
					label: '专业',
					key: 'specialityTwo',
					width: 80
				}, {
					label: '调剂录取的大学',
					key: 'school',
				}],
			}
		},
		methods: {
			reachBottom() {
				if (this.status == 'nomore') return;
				this.status = 'loading';
				this.txGoPage.pageNum++;
				this.getAdjustGoListData();
			},
			//同校去向
			getAdjustGoListData() {
				uni.showLoading({
					mask: true
				});
				getAdjustGoList({
					schoolCode: this.schoolCode,
					majorCode: this.majorCode,
					...this.txGoPage
				}).then(res => {
					console.log('res: ',res);
					if (res.code == 100000) {
						if (res.data && res.data.data.length) {
							if (this.txGoPage.pageNum == 1) {
								this.msg = res.msg;
								this.txTableData = res.data.data.map(e => {
									return {
										year: e.year,
										name: this.cus(e.studentName),
										total: e.firstTotal,
										english: e.english,
										politics: e.politics,
										specialityOne: e.major1,
										specialityTwo: e.major2,
										school: e.schoolName,
									}
								})
							} else {
								let list = res.data.data.map(e => {
									return {
										year: e.year,
										name: this.cus(e.studentName),
										total: e.firstTotal,
										english: e.english,
										politics: e.politics,
										specialityOne: e.major1,
										specialityTwo: e.major2,
										school: e.schoolName,
									}
								});
								this.txTableData.push(...list);
							}
						}
						if (!res.data || !res.data.data || res.data.data.length < this.txGoPage.pageSize) {
							this.status = 'nomore';
						} else {
							this.status = 'loading';
						}
					}
				}).finally(() => {
					uni.hideLoading();
				})
			},
			//姓名脱敏
			cus(name) {
				if (name && name != undefined && name != '') {
					let name2 = '';
					if (name.length == 2) {
						name = name.substring(0, 1) + '*'
					}
					if (name.length > 2) {
						name = name.substring(0, 1) + '*' + name.charAt(name.length - 1)
					}
					return name
				} else {
					return name
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	.tips {
		background-color: #FFFFDD;
		color: #333333;
		font-size: 24rpx;
		height: 88rpx;
		display: flex;
		align-items: center;
		padding-left: 25rpx;
		padding-right: 25rpx;
		border-radius: 12rpx;
		font-weight: 600;
	}
</style>